package com.cnxdc.demo.controller;

import com.cnxdc.demo.service.ArticleService;
import com.cnxdc.demo.vo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    @PostMapping
    public String addArticle(@RequestBody Article article) {
        articleService.add(article);
        return "success";
    }
    //  http://localhost:8888/article
    @GetMapping
    public List<Article> getArticles() {
        return articleService.getall();
    }
}
